#include <LuaPlus.h>
using namespace LuaPlus;

#include <iostream>
using std::cout;
using std::endl;

#include <string>

/*LuaObject GetTableOfObjs(LuaState *L) {
    return L->GetGlobal("EDUI")["__objects__"];
}

LuaObject AddToObjs(LuaState *L, int* key) {
    LuaObject obj;
    obj.AssignInteger(L, *key);
    return GetTableOfObjs(L).Set(key, obj);
}

int GetFromObjs(LuaState *L, void* key) {
    LuaObject obj = GetTableOfObjs(L).Get(key);
    return obj.GetInteger();
}*/

int g_a;
void* GetInterface(void*) {
    g_a = 10;
    return &g_a;
}

int main() {
    LuaState *L = LuaState::Create(true);

    LuaObject ns = L->GetGlobals().CreateTable("EDUI");
    ns.CreateTable("__objects__");
    /*

    int a = 10;
    int b = 20;
    int c = 30;

    AddToObjs(L, &a);
    AddToObjs(L, &b);
    AddToObjs(L, &c);

    cout << GetFromObjs(L, &a) << endl;
    cout << GetFromObjs(L, &b) << endl;
    cout << GetFromObjs(L, &c) << endl;

    */

    /*int aa = 10;
    int* bb = &aa;
    int cc = 20;
    cc = (int)bb;

    cout << sizeof(int*) << endl;
    cout << sizeof(int) << endl;

    cout << bb << endl;
    cout << *bb << endl;
    cout <<(unsigned int) cc << endl;
    //cout << *((int*)cc) << endl;


    cout << "--------------" << endl;
    {
        auto fun = [](void *key) -> std::string {
            std::string idx;

            

            idx = std::to_string((uint64_t)key);

            return std::move(idx);
        };

        int aa = 10;
        int* bb = &aa;
        cout << bb << endl;

        auto str = fun(bb);
        cout << str << endl;
    }*/

    {
        ns.RegisterDirect("test", GetInterface);
    }

    LuaState::Destroy(L);
    return 0;
}